import chardet

if __name__ == '__main__':
    # 读取文件内容
    with open('urge_log.csv', 'rb') as file:
        file_content = file.read()

    # 检测文件编码
    detected = chardet.detect(file_content)
    print(detected)

    # print(f"Detected encoding: {detected_encoding} with confidence: {confidence}")

    # # 尝试使用检测到的编码解码文件内容
    # try:
    #     decoded_content = file_content.decode(detected_encoding)
    #     print("File content:")
    #     print(decoded_content)
    # except UnicodeDecodeError:
    #     print(f"Failed to decode file using detected encoding: {detected_encoding}")
